package hu;

import java.util.*;

/**
 * 最长公共字串，经典的动态规划
 */
public class hu75 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] ch1 = sc.nextLine().toCharArray();
        char[] ch2 = sc.nextLine().toCharArray();
        int[][] dp = new int[ch1.length + 1][ ch2.length + 1];
        int res = 0;
        for (int i = 1; i <= ch1.length; i++) {
            for (int j = 1; j <= ch2.length; j++) {
                if(ch1[i - 1] == ch2[j - 1]){
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                    res = Math.max(res, dp[i][j]);
                }
                else
                    dp[i][j] = 0;
            }
        }
        System.out.println(res);
    }
}
